<template>
    <div class="dialog" v-show="visible">
        <div class="mask"></div>
        <div class="dialog-item">
                <div class="header">
                    <div style="font-size: 25px; cursor:pointer;" @click="cancel">×</div>
                    <slot name="header">{{title}}</slot>
                </div>
                <div class="body">
                    <slot name="body"></slot>
                </div>
                <div class="footer">
                    <slot name="footer"></slot>
                </div>
        </div>
    </div>
</template>
<script>
import { ref, reactive, toRefs, onMounted } from 'vue'
export default {
    props:{
        visible:{
            type:Boolean,
            default:true
        },
        title:{
            type:String,
        }
    },
    setup(props,{emit}) {
        const data=reactive({
            visible:true
        })
        const cancel=()=>{
            emit('click1',data.visible)
        }
        return {...data,cancel}
    }
}
</script>
<style lang="scss" scoped>
.dialog{
    width: 100%;
    height: 100%;
    .mask{
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        background: #000;
        opacity: .5;
        animation: mask 2s linear forwards;
    }
    .dialog-item{
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50% ,-50%);
        width: 50%;
        height: 300px;
        background: #fff;
        animation: dialog-item 1s linear forwards;
    }
    @keyframes mask {
        from{
            opacity: .0;
        }
        to{
            opacity: .8;
        }
    }
    @keyframes dialog-item {
        from{
           top: 25%;
        }
        to{
            top: 50%;
        }
    }
}
</style>